<template>
	<view class="container">
		<view class="wal_det">
			 
			<view class="det_item" v-for="(item, index) in list" :key="index">
				<view class="det_img">
					<image :src="'/static/'+item.type+'_icon.png'"></image>
				</view>
				<view class="det_main">
					<view class="det_tit" :class="item.status === 1 ? 'text-green' : (item.status === 2 ? 'text-red' : '')">{{item.payment}}</view>
					<view class="det_number">{{item.orderid}}</view>
					<view class="det_note">{{item.note}}</view>
					<view class="det_time">{{item.create_time}}</view>
				</view>
				<view class="det_money">+{{item.money}}</view>
			</view>
		</view>
		<view class="uni-loadmore text-white" v-if="showLoadMore">{{loadMoreText}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				lastPage: 0,
				list: [],
				loadMoreText: "加载中...",
				showLoadMore: false
			};
		},
		onUnload() {
			this.page = 1,
			this.lastPage = 0,
			this.list = [],
			this.loadMoreText = "加载更多",
			this.showLoadMore = false;
		},
		onLoad: function (option) {
			this.helper.checkLogin();
			this.getData();
		},
		onReachBottom() {
			// console.log("onReachBottom");
			if (this.page > this.lastPage) {
				this.loadMoreText = "没有更多数据了!"
				return;
			}else{
				this.showLoadMore = true;
				setTimeout(() => {
					this.getData();
				}, 300);
			}
		},
		onPullDownRefresh() {
			this.page = 1,
			this.lastPage = 0,
			this.list = [],
			this.loadMoreText = "加载更多",
			this.showLoadMore = false;
			
			setTimeout(() => {
				this.getData();
			}, 300);
		},
		methods: {
			getData:function(){
				//获取基础参数
				// uni.showLoading({
				// 	title:"数据加载中",
				// 	mask:true
				// })
				let page = this.page;
				var info = uni.getStorageSync("userinfo");
				let timestamp = this.helper.now();
				let sign = this.helper.setSign(['token='+info.token,'page='+page,'timestamp='+timestamp]);
				this.helper.req({
					api:"getRechargeLog",
					timestamp:timestamp,
					data:{token:info.token,page:page},
					header:{sign:sign},
					method:'GET',
				}).then(res=>{
					let current_page = res.data.data.list.current_page;
					let last_page = res.data.data.list.last_page;
					this.page = current_page + 1;
					this.lastPage = last_page;
					this.list = this.list.concat(res.data.data.list.data);
					if (this.page >= this.lastPage) {
						this.loadMoreText = "没有更多数据了!"
					}
					uni.stopPullDownRefresh();
					uni.hideLoading();
				})
			},
			//链接
			toUrl:function(url){
				// console.log(url);
				uni.navigateTo({
					url: url,
				});	
			},
		},
	};
</script>
<style lang="scss">
	page {
	    // background-image: url('@/static/images/person/center-bg.png');
	    // background-size: 100% 100%;
	    // background-repeat: no-repeat;
	    // min-height: 200vw;
		background-color: #b6ccf2;
		// height:100%;
	}
	
	.info_bg{
		position: absolute;
		width: 100%;
		height: 100%;
		left: 0;
		top: 0;
		background-color: #8cabfe;
		opacity: 0.3;
		border-radius:10px;
	}
	
	.wal_det{
		position: relative;
		width: 92vw;
		// height: 30vw;
		margin: 4vw;
		padding: 0;
		background: #fff;
		border-radius: 10rpx;
		.det_item{
			display: flex;
			align-items: center;
			color: #fff;
			font-size: 14px;
			display: flex;
			margin: 0 4vw;
			border-bottom: 0.5px solid #EEE;
			
			.det_img{
				width: 16vw;
				image{
					width: 16vw;
					height: 16vw;
					margin: 4vw 0vw;
				}
			}
			.det_main{
				width: 48vw; 
				view{
					margin-bottom: 10rpx;
				}
				.det_tit{
					width: 48vw;
					 
					font-size: 14px;
				}
				.det_number{
					width: 48vw;
					 
					font-size: 14px;
					color:#DDD;
				}
				.det_time{
					width: 48vw;
					 
					font-size: 14px;
					color:#DDD;
				}
			}
			.det_money{
				width: 20vw;
				font-size: 14px;
				text-align: right;
				color: #353535;
			}
			.cuIcon-right{
				line-height: 16vw;
			}
		}
		.det_item:last-child{
			border: none;
		}
	}
</style>